<?php
/**
 * Created by PhpStorm.
 * User: peter
 * Date: 2018/9/14
 * Time: 下午2:21
 */

namespace app\activity\controller;


use think\Request;

class TravelPeople extends Auth
{
    /**
     * @purpose 添加出行人
     * @param Request $request
     * @return array
     */
    public function add (Request $request)
    {
        $data           = $request->post();
        return  \app\activity\logic\TravelPeople::add($data, self::$uid);
    }

    /**
     * @purpose 获取出行人列表
     * @param Request $request
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function items (Request $request)
    {
        $page           = $request->get('page', 1);
//        $size           = $request->get('size', 1000);
        $size           = 10000;
        $where          = [];
        return          \app\activity\logic\TravelPeople::items($where, $page, $size, self::$uid);
    }

    /**
     * @purpose 通过ID获取单条出行人信息
     * @param Request $request
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function infoById (Request $request)
    {
        $id             = $request->get('id', 0);
        return  \app\activity\logic\TravelPeople::infoById($id, self::$uid);
    }

    /**
     * @purpose 编辑出行人
     * @param Request $request
     * @return array
     */
    public function edit (Request $request)
    {
        $data           = $request->post();
        return \app\activity\logic\TravelPeople::edit($data);
    }

    /**
     * @purpose 删除出行人
     * @param Request $request
     * @return array
     * @throws \Exception
     */
    public function del (Request $request)
    {
        $ids            = $request->post('ids', []);
        return \app\activity\logic\TravelPeople::del($ids, self::$uid);
    }
}